<!DOCTYPE html>
<html>

<head>
  <title><%= title %></title>
  
  <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
    integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
    <link rel='stylesheet' href='/css/style.css' />
    <!-- Include the Quill library -->
  <script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
  <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>

</head>

<body class="bg">
  <%- include('../layout/header',{ menu: menu}) -%>

  <div class="content">
    <form id="article" action="./create" method="post" onsubmit="return sub_post(this)">
      <div class="input-group">
          <span class="input-group-addon" id="basic-addon1">标题</span>
          <input id="title" type="text" name="title" class="form-control" placeholder="标题" aria-describedby="basic-addon1">
        </div>
        <div class="input-group">
          <span class="input-group-addon" id="basic-addon1">摘要</span>
          <input id="abstract" type="text" name="abstract" class="form-control" placeholder="摘要" aria-describedby="basic-addon1">
        </div> 
        <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">栏目</span>
            <select name="subjectid" form="article" class="form-control">
                <option value="1">诗词</option>
                <option value="2">散文</option>
                <option value="3">小说</option> 
             </select> 
          </div>
        
        <input id="content" type="text" name="content" style="display: none" class="form-control" placeholder="标题" aria-describedby="basic-addon1">
        <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">内容</span>
            <div id="editor"> 
              </div> 
          </div>

          <div class="input-group">
              <button id="submit" class="btn btn-default" type="submit">Submit</button>
            </div> 
          </form>
  </div>
 
</body>
<!-- Initialize Quill editor -->
<script>
    document.cookie = "test1= <%- title -%>";
    var quill = new Quill('#editor', {
      theme: 'snow'
    });

    document.getElementById('submit').addEventListener('click',sub_post)
    function sub_post(form) {
      var html = document.querySelector('#editor').children[0].innerHTML;
      document.querySelector('#content').val = html 
      html = '<div class="ql-container ql-snow"><div class="ql-editor">'+html+"</div></div>";
      console.log(html)
      $('[name=content]').val(html);
      return true
   
  }
  </script>
<style>
  .content {
    margin-top: 44px;
  }
</style>

</html>